package topcoder.srm222;

import java.util.HashMap;
import java.util.Map;

public class GroceryBagger {
	public int minimumBags(int strength, String[] itemType) {
		int res = 0;

		Map<String, Integer> itemMap = new HashMap<String, Integer>();

		for (String it : itemType) {
			Integer c = itemMap.get(it);
			if (c == null)
				c = 0;
			itemMap.put(it, c + 1);
		}
		
		for(Integer n: itemMap.values()) {
			if(n%strength == 0)
				res = res + (n/strength);
			else
				res = res + (n/strength) + 1;
		}

		return res;
	}
	public static void main(String[] args) {
		GroceryBagger gb = new GroceryBagger();
		String[] s = {"CANNED",   "CANNED",  "PRODUCE",
				 "DAIRY",    "MEAT",    "BREAD",
				 "HOUSEHOLD","PRODUCE", "FROZEN",
				 "PRODUCE", "DAIRY"};
		
		System.out.println(gb.minimumBags(2, s));
	}

}
